<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="embroot.css">
<TITLE>
Referring to ECLiPSe terms
</TITLE>
</HEAD>
<BODY >
<A HREF="embroot009.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="embroot007.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot011.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc25">3.3</A>&nbsp;&nbsp;Referring to ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> terms</H2>

The terms constructed so far (as EC-words) have been volatile, that is they
do not survive an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> execution (due to eg. garbage collection),
<A NAME="@default56"></A>
It is possible to create safe terms
that have been registered with the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> engine and which do
survive execution. The <CODE>EC_ref</CODE> and <CODE>EC_refs</CODE> classes
are provided for this purpose. <CODE>EC_refs</CODE> are vectors of
safe terms.<BR>
<BR>
When you declare an <CODE>EC_ref</CODE> it will contain free variables.
<PRE CLASS="verbatim">
EC_ref X; /* declare one free variable */
EC_refs Tasks(10); /* declare 10 free variables */
</PRE>
<A NAME="@default57"></A>
<CODE>EC_ref</CODE>s work like logical variables. When ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> fails during search
they are reset to old values. They are always guaranteed to refer to
something i.e. they never contain dangling references.
If ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> backtracks to a point in the execution
older than the point at which the references were created, they
return to being free variables, or take on their initial values.<BR>
<BR>
<A NAME="@default58"></A>
It is possible to declare references, giving them an initialiser
but this must be an atomic type that fits into a single word. That
restricts you to atoms, integers and nil.<BR>
<BR>
You can freely assign between an <CODE>EC_ref</CODE> and a <CODE>EC_word</CODE>.<BR>
<BR>
One point to take care of is that assigning such a variable
is not like unification since assignment cannot fail. It
just overwrites the old value. Assignment is very similar
to the <A HREF="../bips/kernel/termmanip/setarg-3.html"><B>setarg/3</B></A><A NAME="@default59"></A> built-in in the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> language.<BR>
<BR>
<HR>
<A HREF="embroot009.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="embroot007.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot011.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
